<template>
  <div class='chart' :id="ttid" >

  </div>
</template>
<script>
import konwnData from "../assets/js/qaData/data_1221.js"
export default {
  props: ["info", "type", "ttid"],
  components: {},
  name: "",
  data() {
    return {};
  },
  methods: {
    showChart() {
      var option = {
        title:{
          text:konwnData.title,
          left: 'center',
          top: 20,
          textStyle: {
            fontSize:"25",
            color: '#fff'
          }
        },
        tooltip: {
          trigger: "item",
          formatter: "{a}<br/>{b}:{c}({d}%)"
        },
        legend: {
          type: "scroll",
          bottom: 10,
          left: "center",
          data: konwnData.data1,
          textStyle:{
            color:"#fff",
            fontSize:"16"
          }
        },
        // color:["gold","green","red","blue"],
        series: [
          {
            name: konwnData.title,
            type: this.type,
            radius: "55%",
            center: ["50%", "45%"],
            label: {
              formatter: "{b}:{d}%"
            },
            roseType: 'radius',
            label:{
              color:"#fff",
              fontSize:"16"
            },
            data: konwnData.data2,
            itemStyle: {
              emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)"
              }
            }
          }
        ]
      };

      // option.legend.data = this.info.result.map(val => val.option);
      // option.series[0].name = this.info.title;
      // option.series[0].data = this.info.result.map(val => {
      //   return {
      //     value: val.content,
      //     name: val.option
      //   };
      // });

      var myChart = echarts.init(document.getElementById(this.ttid));
      myChart.setOption(option);
    }
  },
  created() {
    this.$nextTick(() => {
      this.showChart();
    });
  }
};
</script>
<style lang="scss" scoped>
.chart {
  width: 100%;
  height: 100%;
  background-color: transparent;
}
</style>